package com.weijx.dishes.utils;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * com.weijx.dishes.utils.ReturnResult
 * 描述：
 * on 2025/10/24-下午3:16
 *
 * @author weijx
 */

@Data
@NoArgsConstructor
@AllArgsConstructor
public class ReturnResult<T> {
    private int code;
    private String message;
    private T data;
    private long timestamp;

    public ReturnResult(int code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
        this.timestamp = System.currentTimeMillis();
    }

    public static <T> ReturnResult<T> success(T data) {
        return new ReturnResult<>(200, "成功", data);
    }

    public static <T> ReturnResult<T> success(String message, T data) {
        return new ReturnResult<>(200, message, data);
    }

    public static <T> ReturnResult<T> error(int code, String message) {
        return new ReturnResult<>(code, message, null);
    }

    public static <T> ReturnResult<T> error(int code, String message, T data) {
        return new ReturnResult<>(code, message, data);
    }
}
